const express = require('express');
const app = express();
const http = require('http');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const port = 3000;

// 公开文件
app.use(express.static('public'));

//关在express中间件,要放在路由之前
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());


//允许跨域
const cors = require('cors');
app.use(cors());

app.use('/pg',require('./routes/pg')); //postgres相关


app.listen(port, () => console.log(`Example app listening on port ${port}!`))

// //创建HTTP服务
// let server = http.createServer(app);


// //监听服务端口
// server.listen(port,()=>{
//     console.log('服务已经启用，端口号:'+port);
// });

